#-*- coding:UTF-8 -*-
'''
Created on 2013-6-6

@author: hanjiewu
'''
#生成器
#协同程序是可以运行的独立函数调用，可以暂停或者挂起，并从程序离开的地方继续或者重新开始
def counter(start_at = 0):
    count = start_at
    while True:
        val = (yield count) 
        if val is not None:
            count = val
        else :
            count += 1
count = counter(5)
print count.next()
print count.next()
count.send(9)
print count.next()
count.close()
print count.next()
